cmake_minimum_required(VERSION 3.2)
PROJECT(srpc_demo)

# 源代码库
FILE(GLOB SOURCE_SRPC "protos/common.pb.cc" "srpc/*.cpp")
FILE(GLOB SOURCE_PROTOS "protos/*.pb.cc")
FILE(GLOB SOURCE_SRPC_CLIENT "services/echo_service.cpp" "srpc_client.cpp")
FILE(GLOB SOURCE_SRPC_SERVER "services/echo_service.cpp" "srpc_server.cpp")
FILE(GLOB SOURCE_SYNC_SRPC_CLIENT "services/echo_service.cpp" "sync_srpc_client.cpp")

# 添加头文件目录，主要包含主程序头文件和第三方库头文件
INCLUDE_DIRECTORIES("protos/")
INCLUDE_DIRECTORIES("echo/")
INCLUDE_DIRECTORIES("services/")
INCLUDE_DIRECTORIES(".")
# 设置c++11
add_definitions(-std=c++11)
add_definitions(-g)
add_definitions(-pthread)

# protobuf lib
find_package(Protobuf REQUIRED)
INCLUDE_DIRECTORIES(${Protobuf_INCLUDE_DIRS})

# srpc lib
add_library(srpc ${SOURCE_SRPC})

## main BEGIN
add_executable(srpc_client ${SOURCE_SRPC_CLIENT} ${SOURCE_PROTOS})
#add_executable(sync_srpc_client ${SOURCE_SYNC_SRPC_CLIENT} ${SOURCE_PROTOS})

add_executable(srpc_server ${SOURCE_SRPC_SERVER} ${SOURCE_PROTOS})

find_library(EVENT event /usr/local/lib/)
message(STATUS "【LOG】Load libevent from ${EVENT}")

# message(WARNING ${Protobuf_LIBRARY})
target_link_libraries(srpc_client ${Protobuf_LIBRARY} ${EVENT} srpc)
target_link_libraries(srpc_server ${Protobuf_LIBRARY} ${EVENT} srpc)
#target_link_libraries(sync_srpc_client ${Protobuf_LIBRARY} ${EVENT} srpc)
## main END
